package com.android.fastwebview.activity

import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import com.android.fastwebview.R
import com.android.fastwebview.webview.FastWebView
import com.android.fastwebview.webview.WebViewPool
import kotlinx.android.synthetic.main.activity_web.*

class WebViewActivity: AppCompatActivity() {

    private lateinit var webView: FastWebView
    private val url = "https://xw.qq.com/?f=qqcom"

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_web)
        webView = WebViewPool.acquire(this)
        ll_root.addView(webView)
        webView.loadUrl(url)
    }

    override fun onBackPressed() {
        if (webView.canGoBack()) {
            webView.goBack()
            return
        }
        super.onBackPressed()
    }

    override fun onDestroy() {
        super.onDestroy()
        WebViewPool.preload()
    }

}